package com.baeldung.rate;

import com.baeldung.rate.api.QuoteManager;

import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;

public final class QuoteManagerLoader {

    public static QuoteManager load() {
        List<QuoteManager> managerList = new ArrayList<>();
        ServiceLoader<QuoteManager> loader = ServiceLoader.load(QuoteManager.class);

        loader.forEach(exchangeRateProvider -> {
            managerList.add(exchangeRateProvider);
        });
        return managerList.get(0);
    }
}